import http from '@utils/request'
import { UserRuleForm, PhoneCodeForm, PhoneRuleForm,ILoginRequest } from '@interface/login'

export const captchaImage = (data: { key: string }): Promise<ArrayBuffer> => {
  return http.get<ArrayBuffer>('/captcha/image', data, {
    responseType: 'arraybuffer',
  })
}

export const loginByJson = (data: UserRuleForm): Promise<ILoginRequest> => {
  return http.post<ILoginRequest>('/u/loginByJson', data)
}

export const loginCaptcha = (params: PhoneCodeForm): Promise<ILoginRequest> => {
  return http.get<ILoginRequest>('/captcha/sendRegisterOrLoginCaptcha', params)
}

export const loginByMobile = (data: PhoneRuleForm): Promise<ILoginRequest> => {
  return http.post<ILoginRequest>('/u/loginByMobile', data)
}
